/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.workingtimemanager.urb.entities;

import java.util.Vector;

/**
 *
 * @author CK05102
 */
public class User {

    private final String USERNAME;
    private final String PASSWORD;
    private Vector<Project> projects = new Vector<Project>();
    private boolean active = false;

    public User(String USERNAME, String PASSWORD) {
        this.USERNAME = USERNAME;
        this.PASSWORD = PASSWORD;
        projects.add(new Project("empty", "empty"));
    }

    public User(String USERNAME, String PASSWORD, Project project) {
        this.USERNAME = USERNAME;
        this.PASSWORD = PASSWORD;
        projects.add(new Project("empty", "empty"));
        projects.add(project);
    }

    public String getUSERNAME() {
        return USERNAME;
    }

    public String getPASSWORD() {
        return PASSWORD;
    }

    public Vector<Project> getProjects() {
        return projects;
    }

    public void addProjects(Vector<Project> projects) {
        this.projects = projects;
    }

    public void addProject(Project project) {
        this.projects.add(project);
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }
    
    public Project getActiveProject(){
        for(Project p : projects){
            if(p.isActive()){
                return p;
            }
        }
        return null;
    }
    
       public Project getProjectByName(String name){
        for(Project p : projects){
            if(p.getProjectName().equals(name)){
                return p;
            }
        }
        return null;
    }
}
